<?php
/**
 * Created by litong on Date: 2019/2/24 0024 下午 10:00
 */
$host="localhost";$username="root";$password="";$dbname="php_study";

$sql1 = "INSERT INTO my_guests (firstname, lastname, email)VALUES ('John', 'Doe', 'john@example.com');";
$sql2= "INSERT INTO my_guests (firstname, lastname, email)VALUES ('Mary', 'Moe', 'mary@example.com');";
$sql3= "INSERT INTO my_guests (firstname, lastname, email)VALUES ('Julie', 'Dooley', 'julie@example.com')";

try{
  $connection = new PDO("mysql:host=$host;dbname=$dbname",$username,$password);
  $connection->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  $connection->exec($sql1);
  $connection->exec($sql2);
  $connection->exec($sql3);
  echo "执行成功";
}catch(PDOException $e){
  $e->getMessage();
}